package com.mission.schedule.activity;

import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.BackgroundColorSpan;
import android.text.style.ForegroundColorSpan;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
import com.mission.schedule.R;
import com.mission.schedule.applcation.App;
import com.mission.schedule.bean.BackgroundBean;
import com.mission.schedule.bean.MyMessageBackBean;
import com.mission.schedule.bean.MyMessageBean;
import com.mission.schedule.bean.SuccessOrFailBean;
import com.mission.schedule.constants.ShareFile;
import com.mission.schedule.constants.URLConstants;
import com.mission.schedule.cutimage.Crop;
import com.mission.schedule.my160920.widget.CircleImageView;
import com.mission.schedule.service.DownImageService;
import com.mission.schedule.utils.AfterPermissionGranted;
import com.mission.schedule.utils.DateUtil;
import com.mission.schedule.utils.EasyPermissions;
import com.mission.schedule.utils.ImageUtils;
import com.mission.schedule.utils.ListViewForScrollView;
import com.mission.schedule.utils.NetUtil;
import com.mission.schedule.utils.ProgressUtil;
import com.mission.schedule.utils.RxPhotoUtils;
import com.mission.schedule.utils.SharedPrefUtil;
import com.mission.schedule.utils.StringUtils;
import com.mission.schedule.utils.Utils;
import com.mission.schedule.view.noteeditscroll.OverScrollView;
import com.mission.schedule.widget.SwipeLinearLayout;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
import com.yalantis.ucrop.UCrop;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;

public class MyKzoneActivity extends Activity implements EasyPermissions.PermissionCallbacks {

    OverScrollView scoll;
    ImageView member_relative;
    ImageLoader imageLoader;
    CircleImageView image_img;
    TextView tv_memberlogin, tv_remarklogin, none;
    LinearLayout top_ll_left;
    ListViewForScrollView listViewForScrollView;
    RelativeLayout header_rl;

    SharedPrefUtil sharedPrefUtil = null;
    File outfile;
    DisplayImageOptions options;
    ImageLoadingListener animateFirstListener = new AnimateFirstDisplayListener();

    int mScreenWidth;
    String backgroundname, path, paths, userId;
    Bitmap backgroundbitmap = null;

    int update_img_type = 0;
    String userid = "";
    String name = "";
    String pimage = "";

    ProgressUtil progressUtil;
    int colors[] = {R.color.white, R.color.color_m_1, R.color.color_m_2, R.color.color_m_3, R.color.color_m_4, R.color.color_m_5};

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_kzone);

        sharedPrefUtil = new SharedPrefUtil(this, ShareFile.USERFILE);
        imageLoader = ImageLoader.getInstance();


        userid = getIntent().getStringExtra("userid");
        name = getIntent().getStringExtra("name");
        pimage = getIntent().getStringExtra("pimage");

        userId = sharedPrefUtil.getString(this, ShareFile.USERFILE, ShareFile.USERID, "0");
        if (userid.equals(userId)) {
            backgroundname = sharedPrefUtil.getString(this, ShareFile.USERFILE, ShareFile.USERBACKGROUNDPATH, "");
            if ("".equals(StringUtils.getIsStringEqulesNull(backgroundname))) {
                path = URLConstants.默认背景图片;
            } else {
                path = URLConstants.默认背景图片 + "=" + backgroundname;
            }
        }

        progressUtil = new ProgressUtil();

        DisplayMetrics metric = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metric);
        mScreenWidth = metric.widthPixels;

        scoll = findViewById(R.id.scoll);
        member_relative = findViewById(R.id.member_relative);
        image_img = findViewById(R.id.image_img);
        tv_memberlogin = findViewById(R.id.tv_memberlogin);
        tv_remarklogin = findViewById(R.id.tv_remarklogin);
        top_ll_left = findViewById(R.id.top_ll_left);
        listViewForScrollView = findViewById(R.id.listview);
        none = findViewById(R.id.none);
        header_rl = findViewById(R.id.header_rl);

        init();
        setHeadView();
        click();
        getuserinfo();
        userDetail_findDetailPubicBytitle();

    }

    String imageUrl = "";
    String remark = "";

    void init() {
        tv_memberlogin.setText(name);
        if (userid.equals(userId)) {
            remark = sharedPrefUtil.getString(this, ShareFile.USERFILE, ShareFile.PERSONREMARK, "");
        }
        tv_remarklogin.setText(remark.isEmpty() ? "暂无信息" : remark);
        options = new DisplayImageOptions.Builder().showStubImage(R.mipmap.b1).showImageForEmptyUri(R.mipmap.b1)
                .showImageOnFail(R.mipmap.b1).cacheInMemory(true)
                .cacheOnDisc(true).cacheInMemory(true).bitmapConfig(Bitmap.Config.RGB_565).build();
        String imageUrl = URLConstants.图片 + pimage + "&imageType=2&imageSizeType=3";
        imageLoader.displayImage(imageUrl, image_img, options, animateFirstListener);
        imageLoader.displayImage(path, member_relative, options, animateFirstListener);
        noteExpandListAdapter = new NoteExpandListAdapter(this, itemsBeanList);
    }

    private void setHeadView() {
        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) header_rl.getLayoutParams();
        params.height = mScreenWidth;
        header_rl.setLayoutParams(params);
//        RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) image_img.getLayoutParams();
//        params2.topMargin = mScreenWidth - Utils.dipTopx(this, 95);
//        image_img.setLayoutParams(params2);
//        RelativeLayout.LayoutParams params3 = (RelativeLayout.LayoutParams) tv_memberlogin.getLayoutParams();
//        params3.topMargin = mScreenWidth - Utils.dipTopx(this, 80);
//        tv_memberlogin.setLayoutParams(params3);
//        RelativeLayout.LayoutParams params4 = (RelativeLayout.LayoutParams) tv_remarklogin.getLayoutParams();
//        params4.topMargin = mScreenWidth - Utils.dipTopx(this, 50);
//        tv_remarklogin.setLayoutParams(params4);

        scoll.post(new Runnable() {
            @Override
            public void run() {
                scoll.scrollTo(0, mScreenWidth / 4);
            }
        });
    }

    void click() {
        top_ll_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        if (userid.equals(userId)) {
            member_relative.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    checkPhonePermission();
                    if (autoFag) {
                        Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                        intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
                        startActivityForResult(intent, 5002);
                    } else {
                        Toast.makeText(MyKzoneActivity.this, "权限已禁止访问!", Toast.LENGTH_LONG).show();
                    }
                }
            });
            image_img.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    checkPhonePermission();
                    if (autoFag) {
                        Crop.pickImage(MyKzoneActivity.this);
                    } else {
                        Toast.makeText(MyKzoneActivity.this, "权限已禁止访问!", Toast.LENGTH_LONG).show();
                    }
                }
            });
        }

    }

    private static class AnimateFirstDisplayListener extends SimpleImageLoadingListener {

        static final List<String> displayedImages = Collections.synchronizedList(new LinkedList<String>());

        @Override
        public void onLoadingComplete(String imageUri, View view,
                                      Bitmap loadedImage) {
            if (loadedImage != null) {
                ImageView imageView = (ImageView) view;
                // 是否第一次显示
                boolean firstDisplay = !displayedImages.contains(imageUri);
                if (firstDisplay) {
                    // 图片淡入效果
                    FadeInBitmapDisplayer.animate(imageView, 500);
                    displayedImages.add(imageUri);
                }
            }
        }
    }

    @SuppressWarnings("deprecation")
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);


        if (data != null) {
            String fileName = "HeaderImage_" + String.valueOf(System.currentTimeMillis()) + ".png";

            Uri selectImageUri = data.getData();

            if (selectImageUri != null) {
                Uri mDestinationUri = Uri.fromFile(new File(getCacheDir(), fileName));
                UCrop.of(selectImageUri, mDestinationUri).withMaxResultSize(480, 480).withAspectRatio(1, 1).start(MyKzoneActivity.this);
            }
            if (resultCode == RESULT_OK && requestCode == UCrop.REQUEST_CROP) {
                final Uri resultUri = UCrop.getOutput(data);
                String path = RxPhotoUtils.getRealFilePath(MyKzoneActivity.this, resultUri);
                if (path != null) {
                    paths = path;
                    backgroundbitmap = BitmapFactory.decodeFile(path);
                    if (update_img_type == 0) {
                        if (NetUtil.getConnectState(MyKzoneActivity.this) != NetUtil.NetWorkState.NONE) {
                            uploadJvBaoContent();
                        } else {
                            alertFailDialog(0);
                        }
                    } else {
                        if (backgroundbitmap != null) {
                            image_img.setImageBitmap(backgroundbitmap);
                        }
                        uploadJvBaoContent1();
                    }
                }
            } else if (resultCode == UCrop.RESULT_ERROR) {
                Toast.makeText(MyKzoneActivity.this, "图片裁剪失败!", Toast.LENGTH_SHORT).show();
            }
        }

    }

    private void uploadJvBaoContent() {
        if (NetUtil.getConnectState(MyKzoneActivity.this) == NetUtil.NetWorkState.NONE) {
            Toast.makeText(MyKzoneActivity.this, "网络异常，请检查网络！", Toast.LENGTH_SHORT).show();
        } else {
            final String imagepath = paths;
            backgroundname = paths.substring(paths.lastIndexOf("/") + 1, paths.length());
            HttpUtils httpUtils = new HttpUtils(10000);
            httpUtils.configCurrentHttpCacheExpiry(5000);
            final ProgressUtil progressUtil = new ProgressUtil();
            progressUtil.ShowProgress(MyKzoneActivity.this, true, true, "正在上传......");
            String upImagePath = URLConstants.修改背景图片;
            RequestParams params = new RequestParams();
            params.addBodyParameter("doc", new File(imagepath));
            params.addBodyParameter("id", userId);
            params.addBodyParameter("docFilename", backgroundname);
            httpUtils.send(HttpMethod.POST, upImagePath, params,
                    new RequestCallBack<String>() {

                        @Override
                        public void onFailure(HttpException e, String msg) {
                            progressUtil.dismiss();
                            Toast.makeText(MyKzoneActivity.this, "上传失败！", Toast.LENGTH_SHORT).show();
                        }

                        @Override
                        public void onSuccess(ResponseInfo<String> responseInfo) {
                            progressUtil.dismiss();
                            if (!TextUtils.isEmpty(responseInfo.result)) {
                                Gson gson = new Gson();
                                BackgroundBean bean;
                                try {
                                    bean = gson.fromJson(responseInfo.result, BackgroundBean.class);
                                    if (bean.state.equals("0")) {
                                        member_relative.setImageBitmap(backgroundbitmap);
                                        setResult(1);
                                        UpdateMyMessage();
                                    } else if (bean.state.equals("1")) {
                                        alertFailDialog(1);
                                    } else {
                                        Toast.makeText(MyKzoneActivity.this, responseInfo.result, Toast.LENGTH_SHORT).show();
                                    }
                                } catch (JsonSyntaxException e) {
                                    e.printStackTrace();
                                }
                            } else {
                                Toast.makeText(MyKzoneActivity.this, "上传失败！", Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
        }
    }

    private void uploadJvBaoContent1() {
        if (NetUtil.getConnectState(this) == NetUtil.NetWorkState.NONE) {
            Toast.makeText(MyKzoneActivity.this, "网络异常，请检查网络！", Toast.LENGTH_SHORT).show();
        } else {
            HttpUtils httpUtils = new HttpUtils(10000);
            httpUtils.configCurrentHttpCacheExpiry(1000);
            RequestParams params = new RequestParams();
            params.addBodyParameter("uploadImage", new File(paths));
            params.addBodyParameter("uid", userId);
            httpUtils.send(HttpMethod.POST, URLConstants.修改个人头像, params,
                    new RequestCallBack<String>() {

                        @Override
                        public void onFailure(HttpException e, String msg) {
                            Toast.makeText(MyKzoneActivity.this, "上传失败！", Toast.LENGTH_SHORT).show();
                        }

                        @Override
                        public void onSuccess(ResponseInfo<String> responseInfo) {
                            if (!TextUtils.isEmpty(responseInfo.result)) {
                                Gson gson = new Gson();
                                SuccessOrFailBean bean;
                                try {
                                    bean = gson.fromJson(responseInfo.result, SuccessOrFailBean.class);
                                    if (bean.status == 0) {
                                        image_img.setImageBitmap(ImageUtils.getRoundBitmap(MyKzoneActivity.this, backgroundbitmap));
                                        setResult(1);
                                        sharedPrefUtil.putString(MyKzoneActivity.this, ShareFile.USERFILE, ShareFile.TOUXIANGSTATE, "0");
                                        if (!"头像修改成功".equals(bean.message)) {
                                            sharedPrefUtil.putString(MyKzoneActivity.this, ShareFile.USERFILE, ShareFile.USERPHOTOPATH, bean.message);

                                            String imageUrl = URLConstants.图片 + bean.message + "&imageType=2&imageSizeType=3";

                                            String dicr = Environment.getExternalStorageDirectory() + "/DCIM/";
                                            File outfile = new File(dicr, "TimeApp");
                                            // 如果文件不存在，则创建一个新文件
                                            if (!outfile.isDirectory()) {
                                                try {
                                                    outfile.mkdir();
                                                } catch (Exception e) {
                                                    e.printStackTrace();
                                                }
                                            }

                                            Bitmap bitmapHead = BitmapFactory.decodeFile(outfile + "/" + bean.message.replace('/', '0'));

                                            if (bitmapHead == null) {
                                                imageLoader.displayImage(imageUrl, image_img, options, animateFirstListener);
                                                Intent intent = new Intent(MyKzoneActivity.this, DownImageService.class);
                                                intent.setAction("downimage");
                                                intent.putExtra("url", imageUrl);
                                                intent.putExtra("name", bean.message.replace('/', '0'));
                                                startService(intent);
                                            }
                                        }
                                    } else {
                                        alertFailDialog(1);
                                    }
                                } catch (JsonSyntaxException e) {
                                    e.printStackTrace();
                                }
                            } else {
                            }
                        }
                    });

        }
    }

    private void alertFailDialog(int type) {
        final AlertDialog builder = new AlertDialog.Builder(MyKzoneActivity.this).create();
        builder.show();
        Window window = builder.getWindow();
        WindowManager.LayoutParams params = window.getAttributes();// 获取LayoutParams
        params.alpha = 0.92f;
        params.gravity = Gravity.CENTER;
        window.setAttributes(params);// 设置生效
        window.setGravity(Gravity.CENTER);
        window.setContentView(R.layout.dialog_alert_ok);
        TextView delete_ok = window.findViewById(R.id.delete_ok);
        TextView delete_tv = window.findViewById(R.id.delete_tv);
        if (type == 0) {
            delete_tv.setText("请检查您的网络！");
        } else {
            delete_tv.setText("上传失败！");
        }
        delete_ok.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                builder.cancel();
            }
        });

    }

    private void UpdateMyMessage() {
        String path = URLConstants.查询个人信息 + "?uid=" + userid;
        StringRequest request = new StringRequest(Request.Method.GET, path,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String s) {
                        if (!TextUtils.isEmpty(s)) {
                            Gson gson = new Gson();
                            try {
                                MyMessageBackBean backBean = gson.fromJson(s, MyMessageBackBean.class);
                                if (backBean.status == 0) {
                                    MyMessageBean bean = null;
                                    if (backBean.list != null && backBean.list.size() > 0) {
                                        for (int i = 0; i < backBean.list.size(); i++) {
                                            bean = backBean.list.get(i);
                                        }
                                        sharedPrefUtil.putString(MyKzoneActivity.this, ShareFile.USERFILE, ShareFile.USERBACKGROUNDPATH, bean.uBackgroundImage);
                                        Intent intent = new Intent(MyKzoneActivity.this, DownImageService.class);
                                        intent.setAction("downimage");
                                        intent.putExtra("url", URLConstants.默认背景图片 + "=" + bean.uBackgroundImage);
                                        intent.putExtra("name", bean.uBackgroundImage.replace('/', '0'));
                                        MyKzoneActivity.this.startService(intent);
                                        sharedPrefUtil.putString(MyKzoneActivity.this, ShareFile.USERFILE, ShareFile.USEREMAIL, bean.uEmail);
                                        sharedPrefUtil.putString(MyKzoneActivity.this, ShareFile.USERFILE, ShareFile.TELEPHONE, bean.uMobile);
                                        sharedPrefUtil.putString(MyKzoneActivity.this, ShareFile.USERFILE, ShareFile.USERID, bean.uId);
                                        sharedPrefUtil.putString(MyKzoneActivity.this, ShareFile.USERFILE, ShareFile.USERNAME, bean.uNickName);
                                        sharedPrefUtil.putString(MyKzoneActivity.this, ShareFile.USERFILE, ShareFile.U_ACC_NO, bean.uAccNo);
                                        sharedPrefUtil.putString(MyKzoneActivity.this, ShareFile.USERFILE, ShareFile.PERSONREMARK, bean.uPersontag);
                                        if (!"".equals(bean.uPortrait)) {
                                            String str = bean.uPortrait.toString();
                                            str = str.replace("\\", "");
                                            sharedPrefUtil.putString(MyKzoneActivity.this, ShareFile.USERFILE, ShareFile.USERPHOTOPATH, str);
                                        }
                                    } else {
                                        return;
                                    }
                                }
                            } catch (JsonSyntaxException e) {
                                e.printStackTrace();
                            }
                        } else {
                            return;
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
            }
        });
        request.setTag("down");
        request.setRetryPolicy(new DefaultRetryPolicy(10000, 1, 1.0f));
        App.getHttpQueues().add(request);
    }

    boolean autoFag = false;
    private static final int RC_LOCATION_CONTACTS_PERM = 124;

    @AfterPermissionGranted(RC_LOCATION_CONTACTS_PERM)
    private void checkPhonePermission() {
        if (Build.VERSION.SDK_INT < 23) {
            autoFag = true;
        } else {
            String[] perms = {Manifest.permission.READ_EXTERNAL_STORAGE};
            if (EasyPermissions.hasPermissions(MyKzoneActivity.this, perms)) {
                autoFag = true;
            } else {
                EasyPermissions.requestPermissions(this, "该功能需要此权限，为了保证应用正常运行!", RC_LOCATION_CONTACTS_PERM, perms);
            }
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (PackageManager.PERMISSION_GRANTED == grantResults[0]) {
            autoFag = true;
        } else {
            autoFag = false;
        }
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
    }

    @Override
    public void onPermissionsGranted(int requestCode, List<String> perms) {
        android.util.Log.d("TAG", "onPermissionsGranted:" + requestCode + ":" + perms.size());
    }

    @Override
    public void onPermissionsDenied(int requestCode, List<String> perms) {
        EasyPermissions.checkDeniedPermissionsNeverAskAgain(this,
                getString(R.string.rationale_ask_again),
                R.string.action_settings, R.string.cancel, null, perms);
    }


    List<ZoneBean.PageBean.ItemsBean> itemsBeanList = new ArrayList<>();
    NoteExpandListAdapter noteExpandListAdapter;

    private void userDetail_findDetailPubicBytitle() {
        HttpUtils httpUtils = new HttpUtils(10000);
        RequestParams params = new RequestParams();
        params.addBodyParameter("nowPage", "1");
        params.addBodyParameter("pageNum", "2000");
        params.addBodyParameter("uId", userid);
        httpUtils.send(HttpMethod.POST, URLConstants.我的空间清单标题查询, params, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                if (!TextUtils.isEmpty(responseInfo.result)) {
                    Gson gson = new Gson();
                    ZoneBean publiByTitle = gson.fromJson(responseInfo.result, ZoneBean.class);
                    if (publiByTitle.status == 0) {
                        itemsBeanList.clear();
                        itemsBeanList = publiByTitle.page.items;
                        Collections.sort(itemsBeanList, new Comparator<ZoneBean.PageBean.ItemsBean>() {
                            @Override
                            public int compare(ZoneBean.PageBean.ItemsBean lhs,
                                               ZoneBean.PageBean.ItemsBean rhs) {
                                return DateUtil.parseDateTimeSs(lhs.changeTime.replace('T', ' ')).before(DateUtil.parseDateTimeSs(rhs.changeTime.replace('T', ' '))) ? 1 : -1;
                            }
                        });
                    }
                    noteExpandListAdapter = new NoteExpandListAdapter(MyKzoneActivity.this, itemsBeanList);
                    listViewForScrollView.setAdapter(noteExpandListAdapter);


                    updateadaper();
                }
            }

            @Override
            public void onFailure(HttpException e, String s) {
            }
        });

    }

    private void delete(String titleid, final int position) {
        progressUtil.ShowProgress(MyKzoneActivity.this, true, true, "正在删除...");
        HttpUtils httpUtils = new HttpUtils(10000);
        RequestParams params = new RequestParams();
        params.addBodyParameter("type", "1");
        params.addBodyParameter("titleId", titleid);
        params.addBodyParameter("uId", userid);
        httpUtils.send(HttpMethod.POST, URLConstants.我的空间清单标题操作, params, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                if (!TextUtils.isEmpty(responseInfo.result)) {
                    Gson gson = new Gson();
                    DeleteBean bean = gson.fromJson(responseInfo.result, DeleteBean.class);

                    if (bean.status == 0) {
                        noteExpandListAdapter.deletelist(position);
                        Toast.makeText(MyKzoneActivity.this, "删除成功", Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(MyKzoneActivity.this, "删除失败", Toast.LENGTH_SHORT).show();
                    }
                }
                progressUtil.dismiss();
            }

            @Override
            public void onFailure(HttpException e, String s) {
                progressUtil.dismiss();
                Toast.makeText(MyKzoneActivity.this, "删除失败", Toast.LENGTH_SHORT).show();
            }
        });

    }

    class DeleteBean{

        /**
         * delList : null
         * downTime : 2018-06-27T13:48:39
         * list : null
         * message : 成功
         * page : null
         * status : 0
         * tDelList : null
         */

        private Object delList;
        private String downTime;
        private Object list;
        private String message;
        private Object page;
        private int status;
        private Object tDelList;

        public Object getDelList() {
            return delList;
        }

        public void setDelList(Object delList) {
            this.delList = delList;
        }

        public String getDownTime() {
            return downTime;
        }

        public void setDownTime(String downTime) {
            this.downTime = downTime;
        }

        public Object getList() {
            return list;
        }

        public void setList(Object list) {
            this.list = list;
        }

        public String getMessage() {
            return message;
        }

        public void setMessage(String message) {
            this.message = message;
        }

        public Object getPage() {
            return page;
        }

        public void setPage(Object page) {
            this.page = page;
        }

        public int getStatus() {
            return status;
        }

        public void setStatus(int status) {
            this.status = status;
        }

        public Object getTDelList() {
            return tDelList;
        }

        public void setTDelList(Object tDelList) {
            this.tDelList = tDelList;
        }
    }

    void updateadaper() {
        if (itemsBeanList.size() > 0) {
            listViewForScrollView.setVisibility(View.VISIBLE);
            none.setVisibility(View.GONE);
        } else {
            listViewForScrollView.setVisibility(View.GONE);
            none.setVisibility(View.VISIBLE);
        }
        scoll.post(new Runnable() {
            @Override
            public void run() {
                scoll.scrollTo(0, mScreenWidth / 4);
            }
        });
        noteExpandListAdapter.notifyDataSetChanged();
    }


    class NoteExpandListAdapter extends BaseAdapter {

        Context context;
        LayoutInflater layoutInflater;

        List<ZoneBean.PageBean.ItemsBean> tdellist;

        public NoteExpandListAdapter(Context context,
                                     List<ZoneBean.PageBean.ItemsBean> tdellist) {
            this.context = context;
            this.tdellist = tdellist;
            layoutInflater = LayoutInflater.from(context);
        }

        @Override
        public int getCount() {
            return tdellist.size();
        }

        @Override
        public Object getItem(int position) {
            return tdellist.get(position);
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public boolean hasStableIds() {
            return false;
        }

        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {
            final ChildViewHolder viewHolder;
            if (convertView == null) {
                viewHolder = new ChildViewHolder();
                convertView = layoutInflater.inflate(R.layout.adapter_zone_list, parent, false);
                viewHolder.swipeLayout = convertView.findViewById(R.id.swipeLayout);
                viewHolder.qdll = convertView.findViewById(R.id.qdll);
                viewHolder.time = convertView.findViewById(R.id.time);
                viewHolder.title = convertView.findViewById(R.id.title);
                viewHolder.delete_ll = convertView.findViewById(R.id.delete_ll);
                convertView.setTag(viewHolder);
            } else {
                viewHolder = (ChildViewHolder) convertView.getTag();
            }
            swipeLinearLayouts.add(viewHolder.swipeLayout);
            viewHolder.swipeLayout.setOnSwipeListener(new SwipeLinearLayout.OnSwipeListener() {
                @Override
                public void onDirectionJudged(SwipeLinearLayout thisSll, boolean isHorizontal) {
                    if (false == isHorizontal) {
                        for (SwipeLinearLayout sll : swipeLinearLayouts) {
                            if (null == sll) {
                                continue;
                            }
                            sll.scrollAuto(SwipeLinearLayout.DIRECTION_SHRINK);
                        }
                    } else {
                        ssllayout = position;
                        for (SwipeLinearLayout sll : swipeLinearLayouts) {
                            if (null == sll) {
                                continue;
                            }
                            if (!sll.equals(thisSll)) {
                                //划开一个sll， 其他收缩
                                sll.scrollAuto(SwipeLinearLayout.DIRECTION_SHRINK);
                            }
                        }
                    }
                }
            });
            viewHolder.qdll.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    viewHolder.swipeLayout.scrollAuto(SwipeLinearLayout.DIRECTION_SHRINK);
                    Intent intent = new Intent(MyKzoneActivity.this, ZoneDetailActivity.class);
                    intent.putExtra("type", 0);
                    intent.putExtra("title", itemsBeanList.get(position).titles);
                    intent.putExtra("titleId", itemsBeanList.get(position).titleId);
                    intent.putExtra("path", itemsBeanList.get(position).imgPath);
                    intent.putExtra("goodNum", "0");
                    intent.putExtra("redNum", "1");
                    intent.putExtra("name", name);
                    intent.putExtra("time", itemsBeanList.get(position).createTime);
                    intent.putExtra("num", itemsBeanList.get(position).nums);
                    intent.putExtra("uid", userid);
                    intent.putExtra("stylee", itemsBeanList.get(position).styles);
                    intent.putExtra("imageUrl", imageUrl);
                    intent.putExtra("id", itemsBeanList.get(position).id);
                    startActivity(intent);
                }
            });

            viewHolder.delete_ll.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    viewHolder.swipeLayout.scrollAuto(SwipeLinearLayout.DIRECTION_SHRINK);
                    delete(tdellist.get(position).titleId, position);
                }
            });

            if (!userid.equals(userId)) {
                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                        Utils.dipTopx(MyKzoneActivity.this, 0), RelativeLayout.LayoutParams.MATCH_PARENT);
                viewHolder.delete_ll.setLayoutParams(params);
            }


            if (tdellist.size() > 0) {
                if (tdellist.get(position).titleId != null) {
                    viewHolder.title.setText("");
                    String titlestr;
                    if (tdellist.get(position).titles.isEmpty()) {
                        titlestr = "无标题";
                    } else {
                        titlestr = tdellist.get(position).titles;
                        if (titlestr.length() > 16) {
                            titlestr = titlestr.substring(0, 16);
                        }
                    }
                    viewHolder.title.setTextColor(Color.BLACK);
                    viewHolder.title.setText(titlestr + (tdellist.get(position).remark7 == null ? "" : tdellist.get(position).remark7));
                    if (tdellist.get(position).createTime != null) {
                        viewHolder.time.setText(tdellist.get(position).createTime.replace('T', ' '));
                    }
                }

                String remark6 = tdellist.get(position).remark6;
                if (remark6 == "" || remark6 == null) {
                    remark6 = "0";
                }
                int color = Integer.valueOf(remark6);
                if (color > 0) {
                    SpannableString builder3 = new SpannableString(viewHolder.title.getText().toString());
                    builder3.setSpan(new BackgroundColorSpan(context.getResources().getColor(colors[color])), 0, viewHolder.title.getText().toString().length(),
                            Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
                    if (color > 2) {
                        builder3.setSpan(new ForegroundColorSpan(Color.WHITE), 0, viewHolder.title.getText().toString().length(),
                                Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
                    }
                    viewHolder.title.setText(builder3);
                    viewHolder.title.setLineSpacing(1f, 1f);
                }
            }
            return convertView;
        }

        public void deletelist(int position) {
            tdellist.remove(position);
            notifyDataSetChanged();
        }

        int ssllayout = -1;


        List<SwipeLinearLayout> swipeLinearLayouts = new ArrayList<>();

        class ChildViewHolder {
            SwipeLinearLayout swipeLayout;
            LinearLayout qdll, delete_ll;
            TextView title, time;
        }

        //设置双#号包裹的文字颜色
        private void setcolor(String content, TextView editText) {
            SpannableStringBuilder builder = new SpannableStringBuilder(content);
            if (content.length() > 1) {
                List<Integer> integerList = new ArrayList<>();
                int index = 0;
                int count = hit(content, "#");
                if (count > 1) {
                    if (count % 2 == 0) {
                        for (int i = 0; i < count; i++) {
                            if (i == 0) {
                                index = content.indexOf("#");
                            } else {
                                index = content.indexOf("#", index + 1);
                            }
                            integerList.add(index);
                        }
                        for (int i = 0; i < integerList.size(); i++) {
                            if (i > 0) {
                                if (i % 2 != 0) {
                                    ForegroundColorSpan span = new ForegroundColorSpan(Color.BLACK);
                                    builder.setSpan(span, integerList.get(i - 1), integerList.get(i) + 1, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
                                }
                            }
                        }
                        editText.setText(builder);
                    } else {
                        for (int i = 0; i < count - 1; i++) {
                            if (i == 0) {
                                index = content.indexOf("#");
                            } else {
                                index = content.indexOf("#", index + 1);
                            }
                            integerList.add(index);

                        }
                        for (int i = 0; i < integerList.size(); i++) {
                            if (i > 0) {
                                if (i % 2 != 0) {
                                    ForegroundColorSpan span = new ForegroundColorSpan(Color.BLACK);
                                    builder.setSpan(span, integerList.get(i - 1), integerList.get(i) + 1, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
                                }
                            }
                        }
                        editText.setText(builder);
                    }
                } else {
                    editText.setText(builder);
                }
            } else {
                editText.setText(builder);
            }
        }

        public int hit(String a, String b) {
            if (a.length() < b.length()) {
                return 0;
            }
            char[] a_t = a.toCharArray();
            int count = 0;

            for (int i = 0; i < a.length(); i++) {
                StringBuffer buffer = new StringBuffer();
                for (int j = 0; j < b.length(); j++) {
                    buffer.append(a_t[i + j]);
                }
                if (buffer.toString().equals(b)) {
                    count++;
                }
            }

            return count;
        }
    }


    class ZoneBean {

        /**
         * delList : null
         * downTime : 2018-06-26T13:17:20
         * list : null
         * message : 成功
         * page : {"currentPage":1,"items":[{"appId":"0","cAlarmSound":"","cAlarmSoundDesc":"","cBeforTime":0,"cDate":"","cDisplayAlarm":0,"cImportant":0,"cIsAlarm":1,"cIsEnd":0,"cPostpone":1,"cTime":"","changeTime":"2018-06-26T10:13:00","colorType":0,"copys":"1","createTime":"2018-06-26T10:13:00","filed":"0","goodNum":0,"id":37,"imgPath":"20170420/79502.png","imgUrl":"","isRecommend":0,"isShare":0,"isTop":0,"localTimes":"2018-06-05 16:36:42","ltype":1,"mType":0,"nums":"","openState":1,"orderId":0,"pIsEnd":0,"pname":"","puid":0,"redNum":0,"remark":"0","remark1":"0","remark10":null,"remark2":"0","remark3":"0","remark4":"0","remark5":"0","remark6":"0","remark7":"(9)","remark8":null,"remark9":null,"sends":0,"shareUrl":"","states":0,"styles":1,"taskId":"0","taskImg":"","titleId":"0111","titles":"为什么要用\u201c时间表App\u201d？","uid":1318776,"urlName":"","urlUid":0}],"pageSize":2000,"totalCount":1,"totalPage":1}
         * status : 0
         * tDelList : null
         */

        public Object delList;
        public String downTime;
        public Object list;
        public String message;
        public PageBean page;
        public int status;
        public Object tDelList;

        public Object getDelList() {
            return delList;
        }

        public void setDelList(Object delList) {
            this.delList = delList;
        }

        public String getDownTime() {
            return downTime;
        }

        public void setDownTime(String downTime) {
            this.downTime = downTime;
        }

        public Object getList() {
            return list;
        }

        public void setList(Object list) {
            this.list = list;
        }

        public String getMessage() {
            return message;
        }

        public void setMessage(String message) {
            this.message = message;
        }

        public PageBean getPage() {
            return page;
        }

        public void setPage(PageBean page) {
            this.page = page;
        }

        public int getStatus() {
            return status;
        }

        public void setStatus(int status) {
            this.status = status;
        }

        public Object getTDelList() {
            return tDelList;
        }

        public void setTDelList(Object tDelList) {
            this.tDelList = tDelList;
        }

        public class PageBean {
            /**
             * currentPage : 1
             * items : [{"appId":"0","cAlarmSound":"","cAlarmSoundDesc":"","cBeforTime":0,"cDate":"","cDisplayAlarm":0,"cImportant":0,"cIsAlarm":1,"cIsEnd":0,"cPostpone":1,"cTime":"","changeTime":"2018-06-26T10:13:00","colorType":0,"copys":"1","createTime":"2018-06-26T10:13:00","filed":"0","goodNum":0,"id":37,"imgPath":"20170420/79502.png","imgUrl":"","isRecommend":0,"isShare":0,"isTop":0,"localTimes":"2018-06-05 16:36:42","ltype":1,"mType":0,"nums":"","openState":1,"orderId":0,"pIsEnd":0,"pname":"","puid":0,"redNum":0,"remark":"0","remark1":"0","remark10":null,"remark2":"0","remark3":"0","remark4":"0","remark5":"0","remark6":"0","remark7":"(9)","remark8":null,"remark9":null,"sends":0,"shareUrl":"","states":0,"styles":1,"taskId":"0","taskImg":"","titleId":"0111","titles":"为什么要用\u201c时间表App\u201d？","uid":1318776,"urlName":"","urlUid":0}]
             * pageSize : 2000
             * totalCount : 1
             * totalPage : 1
             */

            public int currentPage;
            public int pageSize;
            public int totalCount;
            public int totalPage;
            public List<ItemsBean> items;

            public int getCurrentPage() {
                return currentPage;
            }

            public void setCurrentPage(int currentPage) {
                this.currentPage = currentPage;
            }

            public int getPageSize() {
                return pageSize;
            }

            public void setPageSize(int pageSize) {
                this.pageSize = pageSize;
            }

            public int getTotalCount() {
                return totalCount;
            }

            public void setTotalCount(int totalCount) {
                this.totalCount = totalCount;
            }

            public int getTotalPage() {
                return totalPage;
            }

            public void setTotalPage(int totalPage) {
                this.totalPage = totalPage;
            }

            public List<ItemsBean> getItems() {
                return items;
            }

            public void setItems(List<ItemsBean> items) {
                this.items = items;
            }

            public class ItemsBean {
                /**
                 * appId : 0
                 * cAlarmSound :
                 * cAlarmSoundDesc :
                 * cBeforTime : 0
                 * cDate :
                 * cDisplayAlarm : 0
                 * cImportant : 0
                 * cIsAlarm : 1
                 * cIsEnd : 0
                 * cPostpone : 1
                 * cTime :
                 * changeTime : 2018-06-26T10:13:00
                 * colorType : 0
                 * copys : 1
                 * createTime : 2018-06-26T10:13:00
                 * filed : 0
                 * goodNum : 0
                 * id : 37
                 * imgPath : 20170420/79502.png
                 * imgUrl :
                 * isRecommend : 0
                 * isShare : 0
                 * isTop : 0
                 * localTimes : 2018-06-05 16:36:42
                 * ltype : 1
                 * mType : 0
                 * nums :
                 * openState : 1
                 * orderId : 0
                 * pIsEnd : 0
                 * pname :
                 * puid : 0
                 * redNum : 0
                 * remark : 0
                 * remark1 : 0
                 * remark10 : null
                 * remark2 : 0
                 * remark3 : 0
                 * remark4 : 0
                 * remark5 : 0
                 * remark6 : 0
                 * remark7 : (9)
                 * remark8 : null
                 * remark9 : null
                 * sends : 0
                 * shareUrl :
                 * states : 0
                 * styles : 1
                 * taskId : 0
                 * taskImg :
                 * titleId : 0111
                 * titles : 为什么要用“时间表App”？
                 * uid : 1318776
                 * urlName :
                 * urlUid : 0
                 */

                public String appId;
                public String cAlarmSound;
                public String cAlarmSoundDesc;
                public int cBeforTime;
                public String cDate;
                public int cDisplayAlarm;
                public int cImportant;
                public int cIsAlarm;
                public int cIsEnd;
                public int cPostpone;
                public String cTime;
                public String changeTime;
                public int colorType;
                public String copys;
                public String createTime;
                public String filed;
                public int goodNum;
                public int id;
                public String imgPath;
                public String imgUrl;
                public int isRecommend;
                public int isShare;
                public int isTop;
                public String localTimes;
                public int ltype;
                public int mType;
                public String nums;
                public int openState;
                public int orderId;
                public int pIsEnd;
                public String pname;
                public int puid;
                public int redNum;
                public String remark;
                public String remark1;
                public String remark10;
                public String remark2;
                public String remark3;
                public String remark4;
                public String remark5;
                public String remark6;
                public String remark7;
                public String remark8;
                public String remark9;
                public int sends;
                public String shareUrl;
                public int states;
                public int styles;
                public String taskId;
                public String taskImg;
                public String titleId;
                public String titles;
                public int uid;
                public String urlName;
                public int urlUid;

                public String getAppId() {
                    return appId;
                }

                public void setAppId(String appId) {
                    this.appId = appId;
                }

                public String getCAlarmSound() {
                    return cAlarmSound;
                }

                public void setCAlarmSound(String cAlarmSound) {
                    this.cAlarmSound = cAlarmSound;
                }

                public String getCAlarmSoundDesc() {
                    return cAlarmSoundDesc;
                }

                public void setCAlarmSoundDesc(String cAlarmSoundDesc) {
                    this.cAlarmSoundDesc = cAlarmSoundDesc;
                }

                public int getCBeforTime() {
                    return cBeforTime;
                }

                public void setCBeforTime(int cBeforTime) {
                    this.cBeforTime = cBeforTime;
                }

                public String getCDate() {
                    return cDate;
                }

                public void setCDate(String cDate) {
                    this.cDate = cDate;
                }

                public int getCDisplayAlarm() {
                    return cDisplayAlarm;
                }

                public void setCDisplayAlarm(int cDisplayAlarm) {
                    this.cDisplayAlarm = cDisplayAlarm;
                }

                public int getCImportant() {
                    return cImportant;
                }

                public void setCImportant(int cImportant) {
                    this.cImportant = cImportant;
                }

                public int getCIsAlarm() {
                    return cIsAlarm;
                }

                public void setCIsAlarm(int cIsAlarm) {
                    this.cIsAlarm = cIsAlarm;
                }

                public int getCIsEnd() {
                    return cIsEnd;
                }

                public void setCIsEnd(int cIsEnd) {
                    this.cIsEnd = cIsEnd;
                }

                public int getCPostpone() {
                    return cPostpone;
                }

                public void setCPostpone(int cPostpone) {
                    this.cPostpone = cPostpone;
                }

                public String getCTime() {
                    return cTime;
                }

                public void setCTime(String cTime) {
                    this.cTime = cTime;
                }

                public String getChangeTime() {
                    return changeTime;
                }

                public void setChangeTime(String changeTime) {
                    this.changeTime = changeTime;
                }

                public int getColorType() {
                    return colorType;
                }

                public void setColorType(int colorType) {
                    this.colorType = colorType;
                }

                public String getCopys() {
                    return copys;
                }

                public void setCopys(String copys) {
                    this.copys = copys;
                }

                public String getCreateTime() {
                    return createTime;
                }

                public void setCreateTime(String createTime) {
                    this.createTime = createTime;
                }

                public String getFiled() {
                    return filed;
                }

                public void setFiled(String filed) {
                    this.filed = filed;
                }

                public int getGoodNum() {
                    return goodNum;
                }

                public void setGoodNum(int goodNum) {
                    this.goodNum = goodNum;
                }

                public int getId() {
                    return id;
                }

                public void setId(int id) {
                    this.id = id;
                }

                public String getImgPath() {
                    return imgPath;
                }

                public void setImgPath(String imgPath) {
                    this.imgPath = imgPath;
                }

                public String getImgUrl() {
                    return imgUrl;
                }

                public void setImgUrl(String imgUrl) {
                    this.imgUrl = imgUrl;
                }

                public int getIsRecommend() {
                    return isRecommend;
                }

                public void setIsRecommend(int isRecommend) {
                    this.isRecommend = isRecommend;
                }

                public int getIsShare() {
                    return isShare;
                }

                public void setIsShare(int isShare) {
                    this.isShare = isShare;
                }

                public int getIsTop() {
                    return isTop;
                }

                public void setIsTop(int isTop) {
                    this.isTop = isTop;
                }

                public String getLocalTimes() {
                    return localTimes;
                }

                public void setLocalTimes(String localTimes) {
                    this.localTimes = localTimes;
                }

                public int getLtype() {
                    return ltype;
                }

                public void setLtype(int ltype) {
                    this.ltype = ltype;
                }

                public int getMType() {
                    return mType;
                }

                public void setMType(int mType) {
                    this.mType = mType;
                }

                public String getNums() {
                    return nums;
                }

                public void setNums(String nums) {
                    this.nums = nums;
                }

                public int getOpenState() {
                    return openState;
                }

                public void setOpenState(int openState) {
                    this.openState = openState;
                }

                public int getOrderId() {
                    return orderId;
                }

                public void setOrderId(int orderId) {
                    this.orderId = orderId;
                }

                public int getPIsEnd() {
                    return pIsEnd;
                }

                public void setPIsEnd(int pIsEnd) {
                    this.pIsEnd = pIsEnd;
                }

                public String getPname() {
                    return pname;
                }

                public void setPname(String pname) {
                    this.pname = pname;
                }

                public int getPuid() {
                    return puid;
                }

                public void setPuid(int puid) {
                    this.puid = puid;
                }

                public int getRedNum() {
                    return redNum;
                }

                public void setRedNum(int redNum) {
                    this.redNum = redNum;
                }

                public String getRemark() {
                    return remark;
                }

                public void setRemark(String remark) {
                    this.remark = remark;
                }

                public String getRemark1() {
                    return remark1;
                }

                public void setRemark1(String remark1) {
                    this.remark1 = remark1;
                }

                public String getRemark10() {
                    return remark10;
                }

                public void setRemark10(String remark10) {
                    this.remark10 = remark10;
                }

                public String getRemark2() {
                    return remark2;
                }

                public void setRemark2(String remark2) {
                    this.remark2 = remark2;
                }

                public String getRemark3() {
                    return remark3;
                }

                public void setRemark3(String remark3) {
                    this.remark3 = remark3;
                }

                public String getRemark4() {
                    return remark4;
                }

                public void setRemark4(String remark4) {
                    this.remark4 = remark4;
                }

                public String getRemark5() {
                    return remark5;
                }

                public void setRemark5(String remark5) {
                    this.remark5 = remark5;
                }

                public String getRemark6() {
                    return remark6;
                }

                public void setRemark6(String remark6) {
                    this.remark6 = remark6;
                }

                public String getRemark7() {
                    return remark7;
                }

                public void setRemark7(String remark7) {
                    this.remark7 = remark7;
                }

                public String getRemark8() {
                    return remark8;
                }

                public void setRemark8(String remark8) {
                    this.remark8 = remark8;
                }

                public String getRemark9() {
                    return remark9;
                }

                public void setRemark9(String remark9) {
                    this.remark9 = remark9;
                }

                public int getSends() {
                    return sends;
                }

                public void setSends(int sends) {
                    this.sends = sends;
                }

                public String getShareUrl() {
                    return shareUrl;
                }

                public void setShareUrl(String shareUrl) {
                    this.shareUrl = shareUrl;
                }

                public int getStates() {
                    return states;
                }

                public void setStates(int states) {
                    this.states = states;
                }

                public int getStyles() {
                    return styles;
                }

                public void setStyles(int styles) {
                    this.styles = styles;
                }

                public String getTaskId() {
                    return taskId;
                }

                public void setTaskId(String taskId) {
                    this.taskId = taskId;
                }

                public String getTaskImg() {
                    return taskImg;
                }

                public void setTaskImg(String taskImg) {
                    this.taskImg = taskImg;
                }

                public String getTitleId() {
                    return titleId;
                }

                public void setTitleId(String titleId) {
                    this.titleId = titleId;
                }

                public String getTitles() {
                    return titles;
                }

                public void setTitles(String titles) {
                    this.titles = titles;
                }

                public int getUid() {
                    return uid;
                }

                public void setUid(int uid) {
                    this.uid = uid;
                }

                public String getUrlName() {
                    return urlName;
                }

                public void setUrlName(String urlName) {
                    this.urlName = urlName;
                }

                public int getUrlUid() {
                    return urlUid;
                }

                public void setUrlUid(int urlUid) {
                    this.urlUid = urlUid;
                }
            }
        }
    }

    private void getuserinfo() {
        String paths = URLConstants.查询个人信息 + "?uid=" + userid;
        StringRequest request = new StringRequest(Request.Method.GET, paths,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String s) {
                        if (!TextUtils.isEmpty(s)) {
                            Gson gson = new Gson();
                            try {
                                MyMessageBackBean backBean = gson.fromJson(s, MyMessageBackBean.class);
                                if (backBean.status == 0) {
                                    if (backBean.list != null && backBean.list.size() > 0) {
                                        backgroundname = backBean.list.get(0).uBackgroundImage;
                                        if ("".equals(StringUtils.getIsStringEqulesNull(backgroundname))) {
                                            path = URLConstants.默认背景图片;
                                        } else {
                                            path = URLConstants.默认背景图片 + "=" + backgroundname;
                                        }
                                        remark = backBean.list.get(0).uPersontag;
                                        name = backBean.list.get(0).uNickName;
                                        pimage = backBean.list.get(0).uPortrait;

                                        init();
                                    }
                                }
                            } catch (JsonSyntaxException e) {
                                e.printStackTrace();
                            }
                        } else {
                            return;
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
            }
        });
        request.setTag("down");
        request.setRetryPolicy(new DefaultRetryPolicy(10000, 1, 1.0f));
        App.getHttpQueues().add(request);
    }

}
